classdef Region
%REGION used to identify an object inside of an OBJ file
%   each object or model in an OBJ file has a name, and a list of values.
%   These values are indices of vertices to connect in triangular order to
%   generate the object. Main functiosn are GetVertexList() which returns a
%   3xn matrix which has vertex1, vertex2, and vertex3 for all the faces in
%   thsi objects. use these values to index the long list of vertices to
%   plot.

   properties
       Faces;
       Name = '';
       F = 1;
   end

   methods
       %returns a list of 3xn collection of which vertices to connect in a
       %trinagle. OBJ FILE MUST BE EXPORTED USIGN TRIANGLES. VERY
       %IMPORTANT, otherwise a lot of liens will be missing.
       function verts = GetVertexList(this)
           list = [];
           for j=1:length(this.Faces)
               list(3*j -2) = this.Faces(j,1);
               list(3*j -1) = this.Faces(j,2);
               list(3*j -0) = this.Faces(j,3);
           end
           verts = unique(list);
       end
       
       %sets the name of this region so that regions can later be analyze.
       %say region1 is the 'StartingRoom', you can query to see how much
       %timewas spend in 'StartingRoom'
       function this = set.Name(this, name)
           this.Name = name;
       end
       

       %DUe to the process of reading an OBj file, faces are added
       %iteratively. This just adds a face to the Regions collection
       function this = AddFace(this, pt1, pt2, pt3)
           this.Faces = [this.Faces' [ pt1, pt2, pt3]']'; 
       end
       
       
       %returns the 3 points part of a face.
       function [a,b,c] = GetFace(this,j)
           a = this.Faces(j,1);
           b = this.Faces(j,2);
           c = this.Faces(j,3);
       end
       
          
   end
end 
